<template>
  <el-dialog
    v-el-drag-dialog
    title="通知详情"
    :visible.sync="visible"
    top="50px"
    width="1024px"
  >
    <el-form ref="dataForm" class="form" :model="temp" label-position="right" label-width="100px">
      <el-form-item label="编号:" prop="businessNoticeCode">
        <el-input v-model="temp.businessNoticeCode" disabled />
      </el-form-item>
      <el-form-item label="紧急程度:" prop="noticeDegree">
        <el-select v-model="temp.noticeDegree" disabled>
          <el-option
            v-for="item in noticeDegreeMap"
            :key="item.value"
            :label="item.desc"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="标题:" prop="title">
        <el-input v-model="temp.title" disabled />
      </el-form-item>
      <el-form-item label="内容:" prop="noticeContent" class="block">
        <div class="editor-container" v-html="temp.noticeContent" />
      </el-form-item>
      <el-form-item label="发出时间:">
        <el-input :value="temp.modifyTime ? moment(temp.modifyTime).format('YYYY-MM-DD HH:mm:ss') : ''" disabled />
      </el-form-item>
      <el-form-item label="发出部门:">
        <el-input v-model="temp.fromOrgName" disabled />
      </el-form-item>
      <el-form-item label="发出人:">
        <el-input v-model="temp.sendName" disabled />
      </el-form-item>
      <el-form-item label="接收部门:">
        <el-input v-model="temp.targetOrgName" disabled />
      </el-form-item>
      <el-form-item label="接收者:">
        <el-input v-model="temp.receiver" disabled />
      </el-form-item>
      <el-form-item label="状态:">
        <el-select v-model="temp.noticeStatus" disabled>
          <el-option
            v-for="item in noticeStatusMap"
            :key="item.value"
            :label="item.desc"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="处理人:">
        <el-input v-model="temp.feedBackName" disabled />
      </el-form-item>
      <el-form-item label="处理时间:">
        <el-input :value="temp.feedBackDt ? moment(temp.feedBackDt).format('YYYY-MM-DD HH:mm:ss') : ''" disabled />
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
  import { queryNoticeDetail } from '@/api'
  import moment from 'dayjs'

  export default {
    name: 'detail',
    props: {
      noticeDegreeMap: {
        type: Array,
        required: true
      },
      noticeStatusMap: {
        type: Array,
        required: true
      }
    },
    data() {
      return {
        moment,
        visible: false,
        temp: {},
        defautData: {}
      }
    },
    methods: {
      open(temp) {
        this.getDefaultData(temp.noticeId)
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
          this.temp = Object.assign(this.temp, temp)
        })
      },
      async getDefaultData(noticeId) {
        const res = await queryNoticeDetail({ noticeId })
        this.defautData = res.data
        this.temp.noticeContent = res.data.noticeContent
      }
    }
  }
</script>

<style lang="scss" scoped>
.form {
  display: flex;
  flex-wrap: wrap;
  & /deep/ .el-form-item {
    width: 50%;
    padding-right: 10px;
    .el-form-item__content > .el-select {
      width: 100%;
    }
  }
  .block {
    width: 100%;
  }
  .editor-container {
    min-height: 500px;
    border: 1px solid #E4E7ED;
    border-radius: 4px;
    padding: 8px;
    overflow: auto;
  }
}
.info-title {
  display: flex;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 20px;
  .title-icon {
    display: inline-block;
    width: 4px;
    height: 18px;
    margin-right: 6px;
    background: $themeColor;
  }
  span {
    font-weight: 700;
    color: $themeColor;
  }
}
</style>
